Expand description
Cranelift code generation library.
Re-exports§
pub use crate::verifier::verify_function;
pub use crate::write::write_function;
pub use cranelift_bforest as bforest;
pub use cranelift_bitset as bitset;
pub use cranelift_control as control;
pub use cranelift_entity as entity;
pub use gimli;
unwind
Modules§
- binemit
- Binary machine code emission.
- cfg_
printer - The
CFGPrinter
utility. - cursor
- Cursor library.
- data_
value - This module gives users to instantiate values that Cranelift understands. These values are used, for example, during interpretation and for wrapping immediates.
- dbg
- Debug tracing helpers.
- dominator_
tree - A Dominator Tree represented as mappings of Blocks to their immediate dominator.
- flowgraph
- A control flow graph represented as mappings of basic blocks to their predecessors and successors.
- ir
- Representation of Cranelift IR functions.
- isa
- Instruction Set Architectures.
- loop_
analysis - A loop analysis represented as mappings of loops to their header Block and parent in the loop tree.
- packed_
option - Compact representation of
Option<T>
for types with a reserved value. - print_
errors - Utility routines for pretty-printing error messages.
- settings
- Shared settings module.
- timing
- Pass timing.
- traversals
- Traversals over the IR.
- verifier
- A verifier for ensuring that functions are well formed. It verifies:
- write
- Converting Cranelift IR to text.
Macros§
- trace
- Even when trace logging is disabled, the trace macro has a significant performance cost so we disable it by default.
Structs§
- Call
Info - Out-of-line data for calls, to keep the size of
Inst
down. - Compile
Error - Compilation error, with the accompanying function to help printing it.
- Context
- Persistent data structures and compilation pipeline.
- Final
- Status of a compiled artifact ready to use.
- Mach
Buffer - A buffer of output to be produced, fixed up, and then emitted to a CodeSink in bulk.
- Mach
Buffer Finalized - A
MachBuffer
once emission is completed: holds generated code and records, without fixups. This allows the type to be independent of the backend. - Mach
Call Site - A call site record resulting from a compilation.
- Mach
Label - A label refers to some offset in a
MachBuffer
. It may not be resolved at the point at which it is used by emitted code; the buffer records “fixups” for references to the label, and will come back and patch the code appropriately when the label’s location is eventually known. - Mach
SrcLoc - A source-location mapping resulting from a compilation.
- Mach
Text Section Builder - Implementation of the
TextSectionBuilder
trait backed byMachBuffer
. - Mach
Trap - A trap record resulting from a compilation.
- Open
Patch Region - Represents the beginning of an editable region in the
MachBuffer
, while code emission is still occurring. AnOpenPatchRegion
is closed byMachBuffer::end_patchable
, consuming theOpenPatchRegion
token in the process. - Patch
Region - A region in the
MachBuffer
code buffer that can be edited prior to finalization. An example of where you might want to use this is for patching instructions that mention constants that won’t be known until later:MachBuffer::start_patchable
can be used to begin the patchable region, instructions can be emitted with placeholder constants, and thePatchRegion
token can be produced byMachBuffer::end_patchable
. Once the values of those constants are known, thePatchRegion::patch
function can be used to get a mutable buffer to the instruction bytes, and the constants uses can be updated directly. - RealReg
- A real (physical) register. This corresponds to one of the target ISA’s named registers and can be used as an instruction operand.
- Reg
- A register named in an instruction. This register can be either a
virtual register or a fixed physical register. It does not have
any constraints applied to it: those can be added later in
MachInst::get_operands()
when theReg
s are converted toOperand
s. - VCode
Constants - This structure tracks the large constants used in VCode that will be emitted separately by the MachBuffer.
- Value
LocRange - Value location range.
- Writable
- A type wrapper that indicates a register type is writable. The
underlying register can be extracted, and the type wrapper can be
built using an arbitrary register. Hence, this type-level wrapper
is not strictly a guarantee. However, “casting” to a writable
register is an explicit operation for which we can
audit. Ordinarily, internal APIs in the compiler backend should
take a
Writable<Reg>
whenever the register is written, and the usual, frictionless way to get one of these is to allocate a new temporary.
Enums§
- Codegen
Error - A compilation error.
- Finalized
Reloc Target - A Relocation target
- Label
Value Loc - The particular location for a value.
- Reloc
Distance - Notion of “relocation distance”. This gives an estimate of how far away a symbol will be from a reference.
- VCode
Constant Data - Identify the different types of constant that can be inserted into VCodeConstants. Tracking these separately instead of as raw byte buffers allows us to avoid some duplication.
Constants§
- VERSION
- Version number of this crate.
Traits§
- Mach
Inst - A machine instruction.
- Mach
Inst Emit - A trait describing the ability to encode a MachInst into binary machine code.
- Mach
Inst Emit State - A trait describing the emission state carried between MachInsts when emitting a function body.
- Text
Section Builder - An object that can be used to create the text section of an executable.
Type Aliases§
- Codegen
Result - A convenient alias for a
Result
that usesCodegenError
as the error type. - Compiled
Code CompiledCode
in its final form (i.e. afterFunctionParameters
have been applied), ready for consumption.- Finalized
Mach Reloc - A relocation resulting from a compilation.
- Value
Labels Ranges - Resulting map of Value labels and their ranges/locations.